package com.tron.dobest.netty.code;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;

import java.util.List;

/**
 * 描述：
 *
 * @author TRON
 * @since 2020-06-17
 */
public class FixedLengthFrameDecoder extends ByteToMessageDecoder {
    @Override
    protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, List<Object> list) throws Exception {
        System.out.println("FixedLengthFrameDecoder--------------------"+byteBuf.toString());
        while (byteBuf.readerIndex() >= 3) {
            ByteBuf buf = byteBuf.readBytes(3);
            list.add(buf);
        }
    }
}
